#pragma once
#include"Poller.h"
#include"Timestamp.h"
#include<vector>
#include<sys/epoll.h>

 class EPollPoller:public Poller
 {
 public:
    EPollPoller(Eventloop* loop);//初始化epoll实例建立与所属EventLoop的关联
    ~EPollPoller() override;

    //重写基类Poller的方法
    Timestamp poll(int timeoutMs,ChannelList *activeChannels) override;
    void updateChannel(Channel *channel) override;
    void removeChannel(Channel *channel) override;
private:
    static const int kInitEventListSize=16;//给定的vector的一个初始长度默认是16，可以面试证明自己看过源码，为啥是静态

    //填写活跃的连接
    void fillActiveChannels(int numEvents,ChannelList* activeChannels) const;
    //更新channel通道
    void update(int operation ,Channel *channel);
    using EventList=std::vector<epoll_event>;

    int epollfd_;
    EventList events_;//这个将来是作为epoll_wait的第二个参数
 };
 
 